package cn.yili12.business.dto;

import cn.yili12.business.entity.UserDb;
import cn.yili12.common.util.TimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 最近通信好友
 */
@Data
@ApiModel
public class LastFriendDTO {
    @ApiModelProperty("编号")
    private String id;
    @ApiModelProperty("姓名")
    private String name;
    @ApiModelProperty("性别")
    private String sex;
    @ApiModelProperty("电话")
    private String phone;
    @ApiModelProperty("组织")
    private Long orgId;
    @ApiModelProperty("头像")
    private String head;
    @ApiModelProperty("最新消息")
    private String lastMsg;
    @ApiModelProperty("最新通信时间")
    private String lastTime;
    @ApiModelProperty("未读消息")
    private Integer unread;
    @ApiModelProperty("是否在线")
    private int status;

    public LastFriendDTO(UserDb user) {
        this.id = String.valueOf(user.getId());
        this.name = user.getName();
        this.sex = user.getSex();
        this.phone = user.getPhone();
        this.orgId = user.getOrgId();
        this.head = user.getHead();
        this.lastMsg = user.getLastMsg();
        this.lastTime = TimeUtil.parse(user.getUpdateTime());
        this.unread = user.getUnread();
    }

    public LastFriendDTO() {
    }
}
